<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/

/**
 * Description of VA_Form_HtmlTag
 *
 * @author chaporgin_a
 */
class VA_Form_Decorator_HtmlTag extends VA_Form_Decorator {
  private $tag;
  private $jQueryMark;
  private $classes;
  public function  __construct($options) {
    $this->tag = $this->getOption('tag', $options);
    $this->jQueryMark = $this->getOption('jQueryMark', $options, FALSE);
    $this->classes = $this->getOption('classes', $options, array());
  }
  public function render($content){
    return sprintf('<%s %s %s>%s</%s>'
            , $this->tag
            , empty ($this->classes)?'':'class="'.join(' ', $this->classes).'"'
            , $this->jQueryMark?'mark="'.$this->jQueryMark.'"':''
            , $content
            , $this->tag
            );
  }
  public function addClass($name){
      if(!in_array($name, $this->classes))
        $this->classes[] = $name;
      return $this;
  }
}